﻿//-----------------------------------------------------------------------
// <copyright file="DTOProduct.cs" company="Transilvania University of Brasov">
//     Copyright (c) Nagy Robert. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace DomainModel
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;

    using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;

    /// <summary>
    /// Describes a Product entity.
    /// </summary>
    public class DTOProduct
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="DTOProduct"/> class.
        /// </summary>
        public DTOProduct()
        {
            this.OfferList = new List<DTOOffer>();
        }

        /// <summary>
        /// Gets or sets id
        /// </summary>
        [Key]
        public int Id { get; set; }

        /// <summary>
        /// Gets or sets the auctioneer that supplied the product
        /// </summary>
        [NotNullValidator(ErrorMessage = "Supplier cannot be null.")]
        public DTOAuctioneer Supplier { get; set; }

        /// <summary>
        /// Gets or sets the name of the product
        /// </summary>
        [NotNullValidator(ErrorMessage = "Name cannot be null.")]
        [StringLengthValidator(2, 50, ErrorMessage = "Name length must be between 2 and 50 characters long.")]
        public string Name { get; set; }

        /// <summary>
        /// Gets or sets the description of the product
        /// </summary>
        [NotNullValidator(ErrorMessage = "Description cannot be null.")]
        [StringLengthValidator(10, 200, ErrorMessage = "Description length must be between 10 and 200 characters long.")]
        public string Description { get; set; }

        /// <summary>
        /// Gets or sets the time at which bidding for the product can start
        /// </summary>
        public DateTime StartTime { get; set; }

        /// <summary>
        /// Gets or sets the time at which bidding for the product will end
        /// </summary>
        [PropertyComparisonValidator(nameof(StartTime), ComparisonOperator.GreaterThan, ErrorMessage = "EndTime must be later that the StartTime")]
        public DateTime EndTime { get; set; }

        /// <summary>
        /// Gets or sets the list of offers made for the product
        /// </summary>
        [NotNullValidator(ErrorMessage = "OfferList cannot be null.")]
        public List<DTOOffer> OfferList { get; set; }

        /// <summary>
        /// Gets or sets the initial value.
        /// </summary>
        [RangeValidator(typeof(decimal), "0.0", RangeBoundaryType.Inclusive, "0.0", RangeBoundaryType.Ignore, ErrorMessage = "Initial value must be positive.")]
        public decimal InitialValue { get; set; }
    }
}
